import {defineStore} from "pinia";

export const useUserStore = defineStore('user', {
    state: () => {
        return {
            username: 'John Doe',
            age: 30,
            isLoggedIn: false,
        }
    },
    actions: {
        updateUser(newName) {
            this.username = newName;
        },
        login(){
            this.isLoggedIn = true;
        },
        logout() {
            this.isLoggedIn = false;
        },
        updateUsername(newUsername){
            this.username = newUsername;
        }
    },
    getters: {
        info: (state) => {
            return `${state.username}: ${state.age}`;
        }
    }
})